/********************************************************************************
  * @file   : SD93F115B_iwdg.h
  * @author   TEST TEAM 													    	
  * @version  v0															    	
  * @date     Septemper 2022												    	
  * @brief   
  *           
  * Copyright (C) 2022  Hangzhou SDIC Microelectronics Co., Ltd
******************************************************************************/

/* Define to prevent recursive inclusion */
#ifndef __SD93F115B_IWDG_H
#define __SD93F115B_IWDG_H

#ifdef __cplusplus
 extern "C" {
#endif

/*********************Includes****************************/

#include "SD93F115B.h"

/********************IWDG_ReloadKey ****************/
#define IWDG_ReloadKey     		    ((uint16_t)0xAAAA)

/****************IWDG_prescaler******************/
#define IWDG_Prescaler_2            ((uint16_t)0x0000)
#define IWDG_Prescaler_4            ((uint16_t)0x0020)
#define IWDG_Prescaler_8            ((uint16_t)0x0040)
#define IWDG_Prescaler_16           ((uint16_t)0x0060)
#define IWDG_Prescaler_32           ((uint16_t)0x0080)
#define IWDG_Prescaler_64           ((uint16_t)0x00A0)
#define IWDG_Prescaler_128          ((uint16_t)0x00C0)
#define IWDG_Prescaler_256          ((uint16_t)0x00E0)

#define IS_IWDG_Prescaler(Prescaler) (((Prescaler) == IWDG_Prescaler_4) ||((Prescaler) == IWDG_Prescaler_8)|| \
                                      ((Prescaler) == IWDG_Prescaler_16)||((Prescaler) == IWDG_Prescaler_32)|| \
                                      ((Prescaler) == IWDG_Prescaler_64)||((Prescaler) == IWDG_Prescaler_128)|| \
                                      ((Prescaler) == IWDG_Prescaler_256))
/**************************IWDG_Reload*******************/

#define IWDG_Reload_256              		((uint16_t)0x0000)
#define IWDG_Reload_6656             		((uint16_t)0x0004)
#define IWDG_Reload_9984             		((uint16_t)0x0008)
#define IWDG_Reload_16384            		((uint16_t)0x000C)
#define IWDG_Reload_23040            		((uint16_t)0x0010)
#define IWDG_Reload_29696            		((uint16_t)0x0014)
#define IWDG_Reload_36096            		((uint16_t)0x0018)
#define IWDG_Reload_65536            		((uint16_t)0x001C)

#define IS_IWDG_Reload(Reload) (((Reload)==IWDG_Reload_256 )||((Reload)==IWDG_Reload_6656)||\
								((Reload)==IWDG_Reload_9984)||((Reload)==IWDG_Reload_16384)||\
								((Reload)==IWDG_Reload_23040)||((Reload)==IWDG_Reload_29696)||\
								((Reload)==IWDG_Reload_36096)||((Reload)==IWDG_Reload_65536))
									
/*********************IWDG_MODE**********************/
typedef enum
{
	
  IWDG_Mode_NoWorking = 0x00,         //正常模式与待机模式都不工作
  IWDG_Mode_Wait = 0x01,              //正常模式不工作（不产生复位），在待机模式下工作（计时）
  IWDG_Mode_Normal = 0x02,            //正常模式工作（复位），在待机模式不工作（不计时） 
  IWDG_Mode_NormalWait = 0x03         //在正常模式和待机模式都工作 
  
}IWDGMode_TypeDef;

#define IS_IWDG_Mode(Mode) (((Mode)==IWDG_Mode_NoWorking)||((Mode)==IWDG_Mode_WAIT)||\
						    ((Mode)==IWDG_Mode_Normal)||((Mode)==IWDG_Mode_NormalWait)) 

/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */

/* Prescaler and Counter configuration functions ******************************/

void IWDG_Init(uint16_t IWDG_Prescaler,uint16_t IWDG_Reload);        //初始化独立看门狗
void IWDG_SetPrescaler(uint16_t IWDG_Prescaler);                     //设置独立看门狗预分频器
void IWDG_SetReload(uint16_t IWDG_Reload);                           //设置独立看门狗重载值
void IWDG_ReloadCounter(void);                                       //重新向独立看门狗计数器载入重载值

void IWDG_Cmd(IWDGMode_TypeDef IWDG_Mode);                           //使能独立看门狗
FlagStatus IWDG_GetIWDTconfig(void);                                 //读取看门狗中配置信息
void IWDG_ITCmd(FunctionalState NewState);                           //使能独立看门狗的中断
ITStatus IWDG_GetITStatus(void);                                     //获取独立看门狗的中断标志位
void IWDG_ClearITStatus(void);                                       //清除独立看门狗的中断标志位

#ifdef __cplusplus
}
#endif

#endif /* __SD93F115B_IWDG_H */ 

/****************************END OF FILE****************************/



